﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MVVMLightDemo.interfaces
{
    /// <summary>
    /// 服务容器
    /// </summary>
   public  interface IServiceContainer
    {
        /// <summary>
        /// 注入一个服务
        /// </summary>
        /// <typeparam name="TInterface"></typeparam>
        /// <typeparam name="TService"></typeparam>
        void Add<TInterface, TService>() where TService : TInterface;

        /// <summary>
        /// 注入一个单实例服务
        /// </summary>
        /// <typeparam name="TInterface">接口的一个实现</typeparam>
        /// <param name="implement"></param>
        void AddSingleton<TInterface>(TInterface implement);

        /// <summary>
        /// 注入一个单实例服务
        /// </summary>
        /// <typeparam name="TInterface"></typeparam>
        /// <typeparam name="TService"></typeparam>
        void AddSingleton<TInterface, TService>() where TService : TInterface;

        /// <summary>
        /// 检查是否存在此服务
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
         bool Contains<T>();

        /// <summary>
        /// 获取服务(通过强类型)
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
         Object GetServices(Type t);

        /// <summary>
        /// 获取服务(通过接口)
        /// </summary>
        /// <typeparam name="TInterface"></typeparam>
        /// <returns></returns>
        TInterface GetServices<TInterface>();
    }
}
